import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import * as path from "path";
// *********************************** 路径配置新增 start  
import { resolve } from 'path'

const pathResolve = (dir: string): any => {
  return resolve(__dirname, ".", dir)
}

const alias: Record<string, string> = {
  '@': path.resolve(__dirname, "src"),
}
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {  // ****************** 路径配置新增
    alias     // ****************** 路径配置新增
  },           // ****************** 路径配置新增
  server: {
    host:'192.168.1.101',
    proxy: {
      // "/api"以及前置字符串会被替换成真正的域名
      "/api": {
        target: "http://47.97.58.151:8089/v1",
        secure: false, //请求是否为https
        changeOrigin: true, //是否为跨域
        rewrite: (path) => path.replace(/^\/api/, "")
      }
    }
  }
})